#ifndef LEAFSEGMENTATION_H
#define LEAFSEGMENTATION_H

#include "imagemask.h"

class LeafSegmentation
{
public:
    static ImageMask segment(const cv::Mat& leaf_img, int num_clusters, int num_segments=2);
    static ImageMask segmentHelperKmeans(const cv::Mat& leaf_img, int num_clusters, int num_segments=2);
    static ImageMask segmentHelperEM(const cv::Mat& leaf_img, int num_clusters, int num_segments=2);
    
    static ImageMask removeFalsePositive(const ImageMask& segmentation_mask, 
                                         double threshold = 0.2, int structure_size=1);
    
    static ImageMask removeStem(ImageMask& segmentation_mask);

    static ImageMask resizeMask(const ImageMask& segmentation_mask, const int target_area=40000);

private:
    static int numPointsOnBorder(const std::vector<cv::Point> contour, cv::Size img_size);
    static void showContour(const cv::Size& size, std::vector<std::vector<cv::Point> > contours);
    
};



#endif // LEAFSEGMENTATION_H
